package com.zjsd.sqeybusiness.controller;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Tcinfo;
import com.zjsd.sqeybusiness.service.ITcinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐信息Controller
 *
 * @author Zheng
 * @date 2022-05-10
 */
@RestController
@RequestMapping("/sqeybusiness/tcinfo")
public class TcinfoController extends BaseController
{
    @Autowired
    private ITcinfoService tcinfoService;

    @Autowired
    private ISysDictDataService sysDictDataService ;


    /**
     * 查询套餐信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Tcinfo tcinfo)
    {
        startPage();
        List<Tcinfo> list = tcinfoService.selectTcinfoList(tcinfo);
        return getDataTable(list);
    }

    /**
     * 导出套餐信息列表
     */
    //@Log(title = "套餐信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Tcinfo tcinfo)
    {
        List<Tcinfo> list = tcinfoService.selectTcinfoList(tcinfo);
        ExcelUtil<Tcinfo> util = new ExcelUtil<Tcinfo>(Tcinfo.class);
        return util.exportExcel(list, "tcinfo");
    }

    /**
     * 获取套餐信息详细信息
     */
    @GetMapping(value = "/{tcid}")
    public AjaxResult getInfo(@PathVariable("tcid") Long tcid)
    {
        return AjaxResult.success(tcinfoService.selectTcinfoById(tcid));
    }

    /**
     * 新增套餐信息
     */
    //@Log(title = "套餐信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tcinfo tcinfo)
    {
        return toAjax(tcinfoService.insertTcinfo(tcinfo));
    }

    /**
     * 修改套餐信息
     */
    //@Log(title = "套餐信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tcinfo tcinfo)
    {
        return toAjax(tcinfoService.updateTcinfo(tcinfo));
    }

    /**
     * 删除套餐信息
     */
    //@Log(title = "套餐信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tcids}")
    public AjaxResult remove(@PathVariable Long[] tcids)
    {
        return toAjax(tcinfoService.deleteTcinfoByIds(tcids));
    }


    @PostMapping("/queryDictData")
    public TableDataInfo list(SysDictData sysDictData)
    {
        //startPage();
        List<SysDictData> list = sysDictDataService.selectDictDataList(sysDictData);
        return getDataTable(list);
    }
}
